package com.gitee.algorithm.test;

import com.gitee.algorithm.linear.Queue;
import com.gitee.algorithm.tree.BinaryTree;

public class DemoBinaryTreeErgodic {
    public static void main(String[] args) {
        //创建对象
        BinaryTree<String,String> tree=new BinaryTree<>();

        //添加数据
        tree.put("E", "5");
        tree.put("B", "2");
        tree.put("G", "7");
        tree.put("A", "1");
        tree.put("D", "4");
        tree.put("F", "6");
        tree.put("H", "8");
        tree.put("C", "3");

        //前序遍历
        Queue<String> keyspre = tree.preErgodic();
        for (String key :keyspre){
            String value = tree.get(key);
            System.out.println(key+"----"+value);
        }

        System.out.println("-------------------");
        Queue<String> keymid = tree.midErgodic();
        for (String key :keymid){
            String value = tree.get(key);
            System.out.println(key+"----"+value);
        }

        System.out.println("-------------------");
        Queue<String> keyafter = tree.afterErgodic();
        for (String key :keyafter){
            String value = tree.get(key);
            System.out.println(key+"----"+value);
        }

    }

}
